package humynn.engine
{
	import flash.events.EventDispatcher;
	import flash.geom.Point;
	import flash.geom.Rectangle;

	/**
	 * The Control class is a base class for all UI controls.
	 */
	public class Control extends EventDispatcher
	{
		protected var _imageFile:String;
		
		protected var _animIndex:uint = 0;
		protected var _animFrame:uint = 0;
		
		protected var _rect:Rectangle;
		
		/**
		 * Sets the initial rectangle for the control.
		 */
		public function Control()
		{
			_rect = new Rectangle();
		}
		
		/**
		 * Sets the new x coordinate.
		 * 
		 * @param value The new x value.
		 */
		public function set x(value:int):void
		{
			_rect.x = value;
		}
		
		/**
		 * Gets the x coordinate.
		 * 
		 * @returns The x coordinate.
		 */
		public function get x():int
		{
			return _rect.x;
		}
		
		/**
		 * Sets the new y coordinate.
		 * 
		 * @param value The new y value.
		 */
		public function set y(value:int):void
		{
			_rect.y = value;
		}
		
		/**
		 * Gets the y coordinate.
		 * 
		 * @returns The y coordinate.
		 */
		public function get y():int
		{
			return _rect.y;
		}
		
		/**
		 * Don't do anything when it's updated by default.
		 */
		public function update(input:Input):void
		{
			
		}
		
		/**
		 * Draw the image associated with the control.
		 * 
		 * @param renderer The renderer to draw to.
		 */
		public function draw(renderer:Renderer):void
		{
			renderer.draw(_imageFile, _animIndex, _animFrame, _rect.x, _rect.y);
		}
	}
}